package com.qiyebox.web.controller.biz;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.qiyebox.common.annotation.Log;
import com.qiyebox.common.enums.BusinessType;
import com.qiyebox.system.domain.TextDetail;
import com.qiyebox.system.service.ITextDetailService;
import com.qiyebox.common.core.controller.BaseController;
import com.qiyebox.common.core.domain.AjaxResult;
import com.qiyebox.common.utils.poi.ExcelUtil;
import com.qiyebox.common.core.page.TableDataInfo;

/**
 * 会议字幕详情Controller
 * 
 * @author qiyebox
 * @date 2025-02-14
 */
@Controller
@RequestMapping("/system/detail")
public class TextDetailController extends BaseController
{
    private String prefix = "system/detail";

    @Autowired
    private ITextDetailService textDetailService;

    @RequiresPermissions("system:detail:view")
    @GetMapping()
    public String detail()
    {
        return prefix + "/detail";
    }

    /**
     * 查询会议字幕详情列表
     */
    @RequiresPermissions("system:detail:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TextDetail textDetail)
    {
        startPage();
        List<TextDetail> list = textDetailService.selectTextDetailList(textDetail);
        return getDataTable(list);
    }

    /**
     * 导出会议字幕详情列表
     */
    @RequiresPermissions("system:detail:export")
    @Log(title = "会议字幕详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TextDetail textDetail)
    {
        List<TextDetail> list = textDetailService.selectTextDetailList(textDetail);
        ExcelUtil<TextDetail> util = new ExcelUtil<TextDetail>(TextDetail.class);
        return util.exportExcel(list, "会议字幕详情数据");
    }

    /**
     * 新增会议字幕详情
     */
    @RequiresPermissions("system:detail:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存会议字幕详情
     */
    @RequiresPermissions("system:detail:add")
    @Log(title = "会议字幕详情", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TextDetail textDetail)
    {
        return toAjax(textDetailService.insertTextDetail(textDetail));
    }

    /**
     * 修改会议字幕详情
     */
    @RequiresPermissions("system:detail:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TextDetail textDetail = textDetailService.selectTextDetailById(id);
        mmap.put("textDetail", textDetail);
        return prefix + "/edit";
    }

    /**
     * 修改保存会议字幕详情
     */
    @RequiresPermissions("system:detail:edit")
    @Log(title = "会议字幕详情", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TextDetail textDetail)
    {
        return toAjax(textDetailService.updateTextDetail(textDetail));
    }

    /**
     * 删除会议字幕详情
     */
    @RequiresPermissions("system:detail:remove")
    @Log(title = "会议字幕详情", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(textDetailService.deleteTextDetailByIds(ids));
    }
}
